import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    searchHisList:JSON.parse(window.localStorage.getItem("searchHisList"))?JSON.parse(window.localStorage.getItem("searchHisList")):[]
  },
  getters: {
  },
  mutations: {
    addSearchHisList(state,payload){
      state.searchHisList=state.searchHisList.filter((n)=>{
        if(payload.value!=n){
          return n
        }
      })
      state.searchHisList.unshift(payload.value);
      window.localStorage.setItem('searchHisList',JSON.stringify(state.searchHisList))
    },
    removeSearchHisList(state,payload){
      state.searchHisList=state.searchHisList.filter((n)=>{
        if(payload.value!=n){
          return n
        }
      })
      window.localStorage.setItem('searchHisList',JSON.stringify(state.searchHisList))
    }
  },
  actions: {
  },
  modules: {
  }
})
